﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>Suspend - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The Suspend function disables or enables all or selected hotkeys and hotstrings." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>Suspend</h1>

<p>禁用或启用所有的或选择的<a href="../Hotkeys.htm">热键</a>和<a href="../Hotstrings.htm">热字串</a>.</p>

<pre class="Syntax"><span class="func">Suspend</span> <span class="optional">Mode</span></pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>Mode</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a>或<a href="../Concepts.htm#numbers">整数</a></p>
    <p>以下值之一:</p>
    <p><strong>On</strong> 或 1 (<a href="../Variables.htm#True">true</a>): 挂起所有的<a href="../Hotkeys.htm">热键</a>和<a href="../Hotstrings.htm">热字串</a>, 备注部分说明的除外.</p>
    <p><strong>Off</strong> 或 0 (<a href="../Variables.htm#False">false</a>): 重新启用上面禁用的热键和热字串.</p>
    <p><strong>Toggle</strong> 或 -1 (默认的): 更改为与以前状态相反的状态(On 或 Off).</p>
  </dd>

</dl>

<h2 id="Remarks">备注</h2>
<p>默认情况下, 脚本也可以通过它的<a href="../Program.htm#tray-icon">托盘图标</a>或<a href="../Program.htm#main-window">主窗口</a>来挂起.</p>
<p>A hotkey/hotstring can be made exempt from suspension by preceding it with the <a href="_SuspendExempt.htm">#SuspendExempt</a> directive. An exempt hotkey/hotstring will remain enabled even while suspension is ON. This allows suspension to be turned off via a hotkey, which would otherwise be impossible since the hotkey would be suspended.</p>
<p>The <a href="_InstallKeybdHook.htm">keyboard</a> and/or <a href="_InstallMouseHook.htm">mouse</a> hooks will be installed or removed if justified by the changes made by this function.</p>
<p>To disable selected hotkeys or hotstrings automatically based on any condition, such as the type of window that is active, use <a href="_If.htm">#If</a>.</p>
<p>Suspending a script's hotkeys does not stop the script's already-running <a href="../misc/Threads.htm">threads</a> (if any); use <a href="Pause.htm">Pause</a> to do that.</p>
<p>When a script's hotkeys are suspended, its tray icon changes to the letter S. This can be avoided by freezing the icon, which is done by specifying 1 for the last parameter of the TraySetIcon function. 例如:</p>
<pre><a href="TraySetIcon.htm">TraySetIcon</a> "C:\My Icon.ico", , 1</pre>
<p>当脚本挂起时, 内置变量 A_IsSuspended 为 1, 否则为 0.</p>

<h2 id="Related">相关</h2>
<p><a href="_SuspendExempt.htm">#SuspendExempt</a>, <a href="../Hotkeys.htm">Hotkeys</a>, <a href="../Hotstrings.htm">Hotstrings</a>, <a href="_If.htm">#If</a>, <a href="Pause.htm">Pause</a>, <a href="ExitApp.htm">ExitApp</a></p>

<h2 id="Examples">示例</h2>
<div class="ex" id="ExHotkey">
<p><a href="#ExHotkey">#1</a></p>
<pre>^!s::Suspend  <em>; 设置一个切换挂起功能的热键.</em></pre>
</div>

<div class="ex" id="ExPostMessage">
<p><a href="#ExPostMessage">#2</a>: 发送 Suspend 函数到另一个脚本.</p>
<pre>DetectHiddenWindows True
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404
<a href="PostMessage.htm">PostMessage</a> WM_COMMAND, ID_FILE_SUSPEND,,, "C:\YourScript.ahk ahk_class AutoHotkey"</pre>
</div>

</body>
</html>